﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Fawcett.Plugins.Panels
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();

            GlobalEvent.MyEvent += this.PluginEventHandler;
        }

        public void PluginEventHandler(object sender, EPlugin p)
        {

            if (p.GetCode == PluginCode.FROM_FSX)
            {
                if (this.Visible == false) return;

                switch( p.GetOffset )
                {
                    case "FSX_HEIGHT":
                        this.pfd1.height = p.GetValue;
                        break;
                    case "FSX_PITCH":
                        this.pfd1.PitchAngle = p.GetValue;
                        break;
                    case "FSX_ROLL":
                        this.pfd1.RollAngle = p.GetValue;
                        break;
                    case "FSX_AIR_SPEED":
                        this.pfd1.speed = p.GetValue;
                        break;
                    case "FSX_HEADING":
                        this.pfd1.heading = p.GetValue;
                        break;
                    default:
                        break;
                }
            }
        }


        private void height_ValueChanged(object sender, EventArgs e)
        {
            GlobalEvent.FireEvent(this, new EPlugin(PluginCode.FROM_FSX, "FSX_HEIGHT", height.Value ));
        }

        private void heading_ValueChanged(object sender, EventArgs e)
        {
            GlobalEvent.FireEvent(this, new EPlugin(PluginCode.FROM_FSX, "FSX_HEADING", heading.Value));
        }

        private void pitch_ValueChanged(object sender, EventArgs e)
        {
            GlobalEvent.FireEvent(this, new EPlugin(PluginCode.FROM_FSX, "FSX_PITCH", pitch.Value));
        }

        private void role_ValueChanged(object sender, EventArgs e)
        {
            GlobalEvent.FireEvent(this, new EPlugin(PluginCode.FROM_FSX, "FSX_ROLL", role.Value ));
        }

        private void speed_ValueChanged(object sender, EventArgs e)
        {
            GlobalEvent.FireEvent(this, new EPlugin(PluginCode.FROM_FSX, "FSX_AIR_SPEED", speed.Value ));
        }
    }
}
